using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;
namespace Lifter.Gui.Monitor.Controls.Buttons
{
    public class ButtonXP : Button
    {
        public enum ControlState
        {
            Normal,
            Hover,
            Pressed,
            Default,
            Disabled
        }
        private Container components = null;
        private ButtonXP.ControlState enmState = ButtonXP.ControlState.Normal;
        private bool bCanClick = false;
        private Point locPoint;
        private static readonly Size sizeBorderPixelIndent;
        private static readonly Color clrOuterShadow1;
        private static readonly Color clrOuterShadow2;
        private static readonly Color clrBackground1;
        private static readonly Color clrBackground2;
        private static readonly Color clrBorder;
        private static readonly Color clrInnerShadowBottom1;
        private static readonly Color clrInnerShadowBottom2;
        private static readonly Color clrInnerShadowBottom3;
        private static readonly Color clrInnerShadowRight1a;
        private static readonly Color clrInnerShadowRight1b;
        private static readonly Color clrInnerShadowRight2a;
        private static readonly Color clrInnerShadowRight2b;
        private static readonly Color clrInnerShadowBottomPressed1;
        private static readonly Color clrInnerShadowBottomPressed2;
        private static readonly Color clrInnerShadowTopPressed1;
        private static readonly Color clrInnerShadowTopPressed2;
        private static readonly Color clrInnerShadowLeftPressed1;
        private static readonly Color clrInnerShadowLeftPressed2;
        private emunType.XPStyle m_btnStyle = emunType.XPStyle.Default;
        private emunType.BtnShape m_btnShape = emunType.BtnShape.Rectangle;
        public new FlatStyle FlatStyle
        {
            get
            {
                return base.FlatStyle;
            }
            set
            {
                base.FlatStyle = FlatStyle.Standard;
            }
        }
        public emunType.BtnShape BtnShape
        {
            get
            {
                return this.m_btnShape;
            }
            set
            {
                this.m_btnShape = value;
                base.Invalidate();
            }
        }
        [DefaultValue("Blue"), RefreshProperties(RefreshProperties.Repaint)]
        public emunType.XPStyle BtnStyle
        {
            get
            {
                return this.m_btnStyle;
            }
            set
            {
                this.m_btnStyle = value;
                base.Invalidate();
            }
        }
        public Point AdjustImageLocation
        {
            get
            {
                return this.locPoint;
            }
            set
            {
                this.locPoint = value;
                base.Invalidate();
            }
        }
        private Rectangle BorderRectangle
        {
            get
            {
                Rectangle clientRectangle = base.ClientRectangle;
                return new Rectangle(1, 1, clientRectangle.Width - 3, clientRectangle.Height - 3);
            }
        }
        public ButtonXP()
        {
            this.InitializeComponent();
            base.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
        }
        static ButtonXP()
        {
            ButtonXP.sizeBorderPixelIndent = new Size(4, 4);
            ButtonXP.clrOuterShadow1 = Color.FromArgb(64, 164, 164, 164);
            ButtonXP.clrOuterShadow2 = Color.FromArgb(64, Color.White);
            ButtonXP.clrBackground1 = Color.FromArgb(250, 250, 248);
            ButtonXP.clrBackground2 = Color.FromArgb(240, 240, 234);
            ButtonXP.clrBorder = Color.FromArgb(0, 60, 116);
            ButtonXP.clrInnerShadowBottom1 = Color.FromArgb(236, 235, 230);
            ButtonXP.clrInnerShadowBottom2 = Color.FromArgb(226, 223, 214);
            ButtonXP.clrInnerShadowBottom3 = Color.FromArgb(214, 208, 197);
            ButtonXP.clrInnerShadowRight1a = Color.FromArgb(128, 236, 234, 230);
            ButtonXP.clrInnerShadowRight1b = Color.FromArgb(128, 224, 220, 212);
            ButtonXP.clrInnerShadowRight2a = Color.FromArgb(128, 234, 228, 218);
            ButtonXP.clrInnerShadowRight2b = Color.FromArgb(128, 212, 208, 196);
            ButtonXP.clrInnerShadowBottomPressed1 = Color.FromArgb(234, 233, 227);
            ButtonXP.clrInnerShadowBottomPressed2 = Color.FromArgb(242, 241, 238);
            ButtonXP.clrInnerShadowTopPressed1 = Color.FromArgb(209, 204, 193);
            ButtonXP.clrInnerShadowTopPressed2 = Color.FromArgb(220, 216, 207);
            ButtonXP.clrInnerShadowLeftPressed1 = Color.FromArgb(216, 213, 203);
            ButtonXP.clrInnerShadowLeftPressed2 = Color.FromArgb(222, 220, 211);
        }
        protected override void OnClick(EventArgs ea)
        {
            base.Capture = false;
            this.bCanClick = false;
            if (base.ClientRectangle.Contains(base.PointToClient(Control.MousePosition)))
            {
                this.enmState = ButtonXP.ControlState.Hover;
            }
            else
            {
                this.enmState = ButtonXP.ControlState.Normal;
            }
            base.Invalidate();
            base.OnClick(ea);
        }
        protected override void OnMouseEnter(EventArgs ea)
        {
            base.OnMouseEnter(ea);
            this.enmState = ButtonXP.ControlState.Hover;
            base.Invalidate();
        }
        protected override void OnMouseDown(MouseEventArgs mea)
        {
            base.OnMouseDown(mea);
            if (mea.Button == MouseButtons.Left)
            {
                this.bCanClick = true;
                this.enmState = ButtonXP.ControlState.Pressed;
                base.Invalidate();
            }
        }
        protected override void OnMouseMove(MouseEventArgs mea)
        {
            base.OnMouseMove(mea);
            if (base.ClientRectangle.Contains(mea.X, mea.Y))
            {
                if (this.enmState == ButtonXP.ControlState.Hover && base.Capture && !this.bCanClick)
                {
                    this.bCanClick = true;
                    this.enmState = ButtonXP.ControlState.Pressed;
                    base.Invalidate();
                }
            }
            else
            {
                if (this.enmState == ButtonXP.ControlState.Pressed)
                {
                    this.bCanClick = false;
                    this.enmState = ButtonXP.ControlState.Hover;
                    base.Invalidate();
                }
            }
        }
        protected override void OnMouseLeave(EventArgs ea)
        {
            base.OnMouseLeave(ea);
            this.enmState = ButtonXP.ControlState.Normal;
            base.Invalidate();
        }
        protected override void OnPaint(PaintEventArgs pea)
        {
            this.OnPaintBackground(pea);
            switch (this.enmState)
            {
                case ButtonXP.ControlState.Normal:
                    if (base.Enabled)
                    {
                        if (this.Focused || base.IsDefault)
                        {
                            switch (this.m_btnShape)
                            {
                                case emunType.BtnShape.Rectangle:
                                    this.OnDrawDefault(pea.Graphics);
                                    break;
                                case emunType.BtnShape.Ellipse:
                                    this.OnDrawDefaultEllipse(pea.Graphics);
                                    break;
                            }
                        }
                        else
                        {
                            switch (this.m_btnShape)
                            {
                                case emunType.BtnShape.Rectangle:
                                    this.OnDrawNormal(pea.Graphics);
                                    break;
                                case emunType.BtnShape.Ellipse:
                                    this.OnDrawNormalEllipse(pea.Graphics);
                                    break;
                            }
                        }
                    }
                    else
                    {
                        this.OnDrawDisabled(pea.Graphics);
                    }
                    break;
                case ButtonXP.ControlState.Hover:
                    switch (this.m_btnShape)
                    {
                        case emunType.BtnShape.Rectangle:
                            this.OnDrawHover(pea.Graphics);
                            break;
                        case emunType.BtnShape.Ellipse:
                            this.OnDrawHoverEllipse(pea.Graphics);
                            break;
                    }
                    break;
                case ButtonXP.ControlState.Pressed:
                    switch (this.m_btnShape)
                    {
                        case emunType.BtnShape.Rectangle:
                            this.OnDrawPressed(pea.Graphics);
                            break;
                        case emunType.BtnShape.Ellipse:
                            this.OnDrawPressedEllipse(pea.Graphics);
                            break;
                    }
                    break;
            }
            this.OnDrawTextAndImage(pea.Graphics);
        }
        protected override void OnEnabledChanged(EventArgs ea)
        {
            base.OnEnabledChanged(ea);
            this.enmState = ButtonXP.ControlState.Normal;
            base.Invalidate();
        }
        private void OnDrawNormal(Graphics g)
        {
            this.DrawNormalButton(g);
        }
        private void OnDrawHoverEllipse(Graphics g)
        {
            this.DrawNormalEllipse(g);
            this.DrawEllipseHoverBorder(g);
            this.DrawEllipseBorder(g);
        }
        private void OnDrawHover(Graphics g)
        {
            this.DrawNormalButton(g);
            Rectangle borderRectangle = this.BorderRectangle;
            Pen pen = new Pen(Color.FromArgb(255, 240, 207));
            Pen pen2 = new Pen(Color.FromArgb(253, 216, 137));
            g.DrawLine(pen, borderRectangle.Left + 2, borderRectangle.Top + 1, borderRectangle.Right - 2, borderRectangle.Top + 1);
            g.DrawLine(pen2, borderRectangle.Left + 1, borderRectangle.Top + 2, borderRectangle.Right - 1, borderRectangle.Top + 2);
            pen.Dispose();
            pen2.Dispose();
            Pen pen3 = new Pen(Color.FromArgb(248, 178, 48));
            Pen pen4 = new Pen(Color.FromArgb(229, 151, 0));
            g.DrawLine(pen3, borderRectangle.Left + 1, borderRectangle.Bottom - 2, borderRectangle.Right - 1, borderRectangle.Bottom - 2);
            g.DrawLine(pen4, borderRectangle.Left + 2, borderRectangle.Bottom - 1, borderRectangle.Right - 2, borderRectangle.Bottom - 1);
            pen3.Dispose();
            pen4.Dispose();
            Rectangle rect = new Rectangle(borderRectangle.Left + 1, borderRectangle.Top + 3, 2, borderRectangle.Height - 5);
            Rectangle rect2 = new Rectangle(borderRectangle.Right - 2, borderRectangle.Top + 3, 2, borderRectangle.Height - 5);
            LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, Color.FromArgb(254, 221, 149), Color.FromArgb(249, 180, 53), LinearGradientMode.Vertical);
            g.FillRectangle(linearGradientBrush, rect);
            g.FillRectangle(linearGradientBrush, rect2);
            linearGradientBrush.Dispose();
        }
        private void OnDrawPressedEllipse(Graphics g)
        {
            this.DrawPressedEllipse(g);
            this.DrawEllipseBorder(g);
        }
        private void DrawPressedEllipse(Graphics g)
        {
            Rectangle borderRectangle = this.BorderRectangle;
            Rectangle rect = new Rectangle(borderRectangle.X + 1, borderRectangle.Y + 1, borderRectangle.Width - 1, borderRectangle.Height - 1);
            SolidBrush brush = new SolidBrush(Color.FromArgb(226, 225, 218));
            g.FillEllipse(brush, rect);
        }
        private void OnDrawPressed(Graphics g)
        {
            Rectangle borderRectangle = this.BorderRectangle;
            this.DrawOuterShadow(g);
            Rectangle rect = new Rectangle(borderRectangle.X + 1, borderRectangle.Y + 1, borderRectangle.Width - 1, borderRectangle.Height - 1);
            SolidBrush solidBrush = new SolidBrush(Color.FromArgb(226, 225, 218));
            g.FillRectangle(solidBrush, rect);
            solidBrush.Dispose();
            this.DrawBorder(g);
            Pen pen = new Pen(ButtonXP.clrInnerShadowBottomPressed1);
            Pen pen2 = new Pen(ButtonXP.clrInnerShadowBottomPressed2);
            g.DrawLine(pen, borderRectangle.Left + 1, borderRectangle.Bottom - 2, borderRectangle.Right - 1, borderRectangle.Bottom - 2);
            g.DrawLine(pen2, borderRectangle.Left + 2, borderRectangle.Bottom - 1, borderRectangle.Right - 2, borderRectangle.Bottom - 1);
            pen.Dispose();
            pen2.Dispose();
            Pen pen3 = new Pen(ButtonXP.clrInnerShadowTopPressed1);
            Pen pen4 = new Pen(ButtonXP.clrInnerShadowTopPressed2);
            g.DrawLine(pen3, borderRectangle.Left + 2, borderRectangle.Top + 1, borderRectangle.Right - 2, borderRectangle.Top + 1);
            g.DrawLine(pen4, borderRectangle.Left + 1, borderRectangle.Top + 2, borderRectangle.Right - 1, borderRectangle.Top + 2);
            pen3.Dispose();
            pen4.Dispose();
            Pen pen5 = new Pen(ButtonXP.clrInnerShadowLeftPressed1);
            Pen pen6 = new Pen(ButtonXP.clrInnerShadowLeftPressed2);
            g.DrawLine(pen5, borderRectangle.Left + 1, borderRectangle.Top + 3, borderRectangle.Left + 1, borderRectangle.Bottom - 3);
            g.DrawLine(pen6, borderRectangle.Left + 2, borderRectangle.Top + 3, borderRectangle.Left + 2, borderRectangle.Bottom - 3);
            pen5.Dispose();
            pen6.Dispose();
        }
        private void OnDrawNormalEllipse(Graphics g)
        {
            this.DrawNormalEllipse(g);
            this.DrawEllipseBorder(g);
        }
        private void OnDrawDefaultEllipse(Graphics g)
        {
            this.DrawNormalEllipse(g);
            this.DrawEllipseDefaultBorder(g);
            this.DrawEllipseBorder(g);
        }
        private void OnDrawDefault(Graphics g)
        {
            this.DrawNormalButton(g);
            Rectangle borderRectangle = this.BorderRectangle;
            Pen pen = new Pen(Color.FromArgb(206, 231, 255));
            Pen pen2 = new Pen(Color.FromArgb(188, 212, 246));
            g.DrawLine(pen, borderRectangle.Left + 2, borderRectangle.Top + 1, borderRectangle.Right - 2, borderRectangle.Top + 1);
            g.DrawLine(pen2, borderRectangle.Left + 1, borderRectangle.Top + 2, borderRectangle.Right - 1, borderRectangle.Top + 2);
            pen.Dispose();
            pen2.Dispose();
            Pen pen3 = new Pen(Color.FromArgb(137, 173, 228));
            Pen pen4 = new Pen(Color.FromArgb(105, 130, 238));
            g.DrawLine(pen3, borderRectangle.Left + 1, borderRectangle.Bottom - 2, borderRectangle.Right - 1, borderRectangle.Bottom - 2);
            g.DrawLine(pen4, borderRectangle.Left + 2, borderRectangle.Bottom - 1, borderRectangle.Right - 2, borderRectangle.Bottom - 1);
            pen3.Dispose();
            pen4.Dispose();
            Rectangle rect = new Rectangle(borderRectangle.Left + 1, borderRectangle.Top + 3, 2, borderRectangle.Height - 5);
            Rectangle rect2 = new Rectangle(borderRectangle.Right - 2, borderRectangle.Top + 3, 2, borderRectangle.Height - 5);
            LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, Color.FromArgb(186, 211, 245), Color.FromArgb(137, 173, 228), LinearGradientMode.Vertical);
            g.FillRectangle(linearGradientBrush, rect);
            g.FillRectangle(linearGradientBrush, rect2);
            linearGradientBrush.Dispose();
        }
        private void OnDrawDisabled(Graphics g)
        {
            Rectangle borderRectangle = this.BorderRectangle;
            Rectangle rect = new Rectangle(borderRectangle.X + 1, borderRectangle.Y + 1, borderRectangle.Width - 1, borderRectangle.Height - 1);
            SolidBrush solidBrush = new SolidBrush(Color.FromArgb(245, 244, 234));
            g.FillRectangle(solidBrush, rect);
            solidBrush.Dispose();
            Pen pen = new Pen(Color.FromArgb(201, 199, 186));
            ButtonXPPainter.DrawRoundedRectangle(g, pen, borderRectangle, ButtonXP.sizeBorderPixelIndent);
            pen.Dispose();
        }
        private void OnDrawTextAndImage(Graphics g)
        {
            SolidBrush solidBrush;
            if (base.Enabled)
            {
                solidBrush = new SolidBrush(this.ForeColor);
            }
            else
            {
                solidBrush = new SolidBrush(ButtonXPPainter.DisabledForeColor);
            }
            StringFormat stringFormat = ButtonXPPainter.GetStringFormat(this.TextAlign);
            stringFormat.HotkeyPrefix = HotkeyPrefix.Show;
            if (base.Image != null)
            {
                Rectangle r = default(Rectangle);
                Point point = new Point(6, 4);
                ContentAlignment imageAlign = base.ImageAlign;
                if (imageAlign != ContentAlignment.TopCenter)
                {
                    if (imageAlign != ContentAlignment.MiddleCenter)
                    {
                        if (imageAlign != ContentAlignment.MiddleRight)
                        {
                            point.X = 6;
                            point.Y = base.ClientRectangle.Height / 2 - base.Image.Height / 2;
                            r.Width = base.ClientRectangle.Width - base.Image.Width;
                            r.Height = base.ClientRectangle.Height;
                            r.X = base.Image.Width;
                            r.Y = 0;
                        }
                        else
                        {
                            r.Width = base.ClientRectangle.Width - base.Image.Width - 8;
                            r.Height = base.ClientRectangle.Height;
                            r.X = 0;
                            r.Y = 0;
                            point.X = r.Width;
                            point.Y = base.ClientRectangle.Height / 2 - base.Image.Height / 2;
                        }
                    }
                    else
                    {
                        point.X = (base.ClientRectangle.Width - base.Image.Width) / 2;
                        point.Y = (base.ClientRectangle.Height - base.Image.Height) / 2;
                        r.Width = 0;
                        r.Height = 0;
                        r.X = base.ClientRectangle.Width;
                        r.Y = base.ClientRectangle.Height;
                    }
                }
                else
                {
                    point.Y = 2;
                    point.X = (base.ClientRectangle.Width - base.Image.Width) / 2;
                    r.Width = base.ClientRectangle.Width;
                    r.Height = base.ClientRectangle.Height - base.Image.Height - 4;
                    r.X = base.ClientRectangle.X;
                    r.Y = base.Image.Height;
                }
                point.X += this.locPoint.X;
                point.Y += this.locPoint.Y;
                if (base.Enabled)
                {
                    g.DrawImage(base.Image, point);
                }
                else
                {
                    ControlPaint.DrawImageDisabled(g, base.Image, this.locPoint.X, this.locPoint.Y, this.BackColor);
                }
                if (ContentAlignment.MiddleCenter != base.ImageAlign)
                {
                    g.DrawString(this.Text, this.Font, solidBrush, r, stringFormat);
                }
            }
            else
            {
                g.DrawString(this.Text, this.Font, solidBrush, base.ClientRectangle, stringFormat);
            }
            solidBrush.Dispose();
            stringFormat.Dispose();
        }
        private void DrawNormalEllipse(Graphics g)
        {
            Rectangle borderRectangle = this.BorderRectangle;
            LinearGradientBrush linearGradientBrush = null;
            switch (this.m_btnStyle)
            {
                case emunType.XPStyle.Default:
                    linearGradientBrush = new LinearGradientBrush(borderRectangle, ButtonXP.clrBackground1, ButtonXP.clrBackground2, LinearGradientMode.Vertical);
                    break;
                case emunType.XPStyle.Blue:
                    linearGradientBrush = new LinearGradientBrush(borderRectangle, Color.FromArgb(248, 252, 253), Color.FromArgb(172, 171, 201), LinearGradientMode.Vertical);
                    break;
                case emunType.XPStyle.OliveGreen:
                    linearGradientBrush = new LinearGradientBrush(borderRectangle, Color.FromArgb(250, 250, 240), Color.FromArgb(235, 220, 190), LinearGradientMode.Vertical);
                    break;
                case emunType.XPStyle.Silver:
                    linearGradientBrush = new LinearGradientBrush(borderRectangle, Color.FromArgb(253, 253, 253), Color.FromArgb(205, 205, 205), LinearGradientMode.Vertical);
                    break;
            }
            float[] factors = new float[]
            {
                0f,
                0.008f,
                1f
            };
            float[] positions = new float[]
            {
                0f,
                0.22f,
                1f
            };
            linearGradientBrush.Blend = new Blend
            {
                Factors = factors,
                Positions = positions
            };
            g.FillEllipse(linearGradientBrush, borderRectangle);
        }
        private void DrawNormalButton(Graphics g)
        {
            try
            {
                Rectangle borderRectangle = this.BorderRectangle;
                this.DrawOuterShadow(g);
                Rectangle rect = new Rectangle(borderRectangle.X + 1, borderRectangle.Y + 1, borderRectangle.Width - 1, borderRectangle.Height - 1);
                LinearGradientBrush linearGradientBrush = null;
                switch (this.m_btnStyle)
                {
                    case emunType.XPStyle.Default:
                        linearGradientBrush = new LinearGradientBrush(rect, ButtonXP.clrBackground1, ButtonXP.clrBackground2, LinearGradientMode.Vertical);
                        break;
                    case emunType.XPStyle.Blue:
                        linearGradientBrush = new LinearGradientBrush(rect, Color.FromArgb(248, 252, 253), Color.FromArgb(172, 171, 201), LinearGradientMode.Vertical);
                        break;
                    case emunType.XPStyle.OliveGreen:
                        linearGradientBrush = new LinearGradientBrush(rect, Color.FromArgb(250, 250, 240), Color.FromArgb(235, 220, 190), LinearGradientMode.Vertical);
                        break;
                    case emunType.XPStyle.Silver:
                        linearGradientBrush = new LinearGradientBrush(rect, Color.FromArgb(253, 253, 253), Color.FromArgb(205, 205, 205), LinearGradientMode.Vertical);
                        break;
                }
                float[] factors = new float[]
                {
                    0f,
                    0.08f,
                    1f
                };
                float[] positions = new float[]
                {
                    0f,
                    0.32f,
                    1f
                };
                linearGradientBrush.Blend = new Blend
                {
                    Factors = factors,
                    Positions = positions
                };
                g.FillRectangle(linearGradientBrush, rect);
                linearGradientBrush.Dispose();
                this.DrawBorder(g);
                if (emunType.XPStyle.Default == this.m_btnStyle)
                {
                    try
                    {
                        Pen pen = new Pen(ButtonXP.clrInnerShadowBottom1);
                        Pen pen2 = new Pen(ButtonXP.clrInnerShadowBottom2);
                        Pen pen3 = new Pen(ButtonXP.clrInnerShadowBottom3);
                        g.DrawLine(pen, borderRectangle.Left + 1, borderRectangle.Bottom - 3, borderRectangle.Right - 1, borderRectangle.Bottom - 3);
                        g.DrawLine(pen2, borderRectangle.Left + 1, borderRectangle.Bottom - 2, borderRectangle.Right - 1, borderRectangle.Bottom - 2);
                        g.DrawLine(pen3, borderRectangle.Left + 2, borderRectangle.Bottom - 1, borderRectangle.Right - 2, borderRectangle.Bottom - 1);
                        pen.Dispose();
                        pen2.Dispose();
                        pen3.Dispose();
                        Point point = new Point(borderRectangle.Right - 2, borderRectangle.Top + 1);
                        Point point2 = new Point(borderRectangle.Right - 2, borderRectangle.Bottom - 1);
                        Point point3 = new Point(borderRectangle.Right - 1, borderRectangle.Top + 2);
                        Point point4 = new Point(borderRectangle.Right - 1, borderRectangle.Bottom - 2);
                        LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(point, point2, ButtonXP.clrInnerShadowRight1a, ButtonXP.clrInnerShadowRight1b);
                        Pen pen4 = new Pen(linearGradientBrush2);
                        LinearGradientBrush linearGradientBrush3 = new LinearGradientBrush(point3, point4, ButtonXP.clrInnerShadowRight2a, ButtonXP.clrInnerShadowRight2b);
                        Pen pen5 = new Pen(linearGradientBrush3);
                        g.DrawLine(pen4, point, point2);
                        g.DrawLine(pen5, point3, point4);
                        pen4.Dispose();
                        pen5.Dispose();
                        linearGradientBrush2.Dispose();
                        linearGradientBrush3.Dispose();
                        Pen pen6 = new Pen(Color.White);
                        g.DrawLine(pen6, borderRectangle.Left + 2, borderRectangle.Top + 1, borderRectangle.Right - 2, borderRectangle.Top + 1);
                        g.DrawLine(pen6, borderRectangle.Left + 1, borderRectangle.Top + 2, borderRectangle.Right - 1, borderRectangle.Top + 2);
                        g.DrawLine(pen6, borderRectangle.Left + 1, borderRectangle.Top + 3, borderRectangle.Right - 1, borderRectangle.Top + 3);
                        pen6.Dispose();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        private void DrawOuterShadow(Graphics g)
        {
            LinearGradientBrush linearGradientBrush = new LinearGradientBrush(base.ClientRectangle, ButtonXP.clrOuterShadow1, ButtonXP.clrOuterShadow2, LinearGradientMode.Vertical);
            g.FillRectangle(linearGradientBrush, base.ClientRectangle);
            linearGradientBrush.Dispose();
        }
        private void DrawEllipseOuterShadow(Graphics g)
        {
            LinearGradientBrush linearGradientBrush = new LinearGradientBrush(base.ClientRectangle, ButtonXP.clrOuterShadow1, ButtonXP.clrOuterShadow2, LinearGradientMode.Vertical);
            g.FillRectangle(linearGradientBrush, base.ClientRectangle);
            linearGradientBrush.Dispose();
        }
        private void DrawBorder(Graphics g)
        {
            Pen pen = new Pen(ButtonXP.clrBorder);
            ButtonXPPainter.DrawRoundedRectangle(g, pen, this.BorderRectangle, ButtonXP.sizeBorderPixelIndent);
            pen.Dispose();
        }
        private void DrawEllipseBorder(Graphics g)
        {
            Pen pen = new Pen(Color.FromArgb(0, 0, 0));
            SmoothingMode smoothingMode = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.DrawEllipse(pen, this.BorderRectangle);
            g.SmoothingMode = smoothingMode;
            pen.Dispose();
        }
        private void DrawEllipseDefaultBorder(Graphics g)
        {
            Pen pen = new Pen(Color.FromArgb(137, 173, 228), 2f);
            Rectangle rect = new Rectangle(this.BorderRectangle.X + 2, this.BorderRectangle.Y + 1, this.BorderRectangle.Width - 4, this.BorderRectangle.Height - 2);
            SmoothingMode smoothingMode = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.DrawEllipse(pen, rect);
            g.SmoothingMode = smoothingMode;
            pen.Dispose();
        }
        private void DrawEllipseHoverBorder(Graphics g)
        {
            Pen pen = new Pen(Color.FromArgb(248, 178, 48), 2f);
            Rectangle rect = new Rectangle(this.BorderRectangle.X + 2, this.BorderRectangle.Y + 1, this.BorderRectangle.Width - 4, this.BorderRectangle.Height - 2);
            SmoothingMode smoothingMode = g.SmoothingMode;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.DrawEllipse(pen, rect);
            g.SmoothingMode = smoothingMode;
            pen.Dispose();
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (this.components != null)
                {
                    this.components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        private void InitializeComponent()
        {
            this.components = new Container();
        }
    }
}
